package cn.portx.view;

import java.util.List;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import cn.portx.entity.Customer;

import com.bstek.bdf3.dorado.jpa.JpaUtil;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Criteria;
import com.bstek.dorado.data.provider.Page;

@Component
public class CustomerPR {

	@Transactional(readOnly = true)
	@DataProvider
	public void loadCustomer(Page<Customer> page, Criteria criteria) {
		JpaUtil.linq(Customer.class).where(criteria).paging(page);
	}

	@Transactional
	@DataResolver
	public void saveCustomer(List<Customer> customers) {
		JpaUtil.save(customers);
	}

	@Expose
	@Transactional
	public void deleteCustomer(String id) {
		JpaUtil.lind(Customer.class).equal("id", id).delete();
	}
}
